// 加载vue构造函数
import Vue from 'vue'
// 加载vue-router依赖
import VueRouter from 'vue-router'
// ------------------------------------------
// 注册为全局路由
Vue.use(VueRouter)
// 路由表
const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login')
  },
  {
    path: '/',
    component: () => import('@/views/layout'),
    children: [
      {
        path: '', //默认子路由(只能有一个)
        name: 'home',
        component: () => import('@/views/home')
      },
      {
        path: '/my',
        name: 'my',
        component: () => import('@/views/my')
      },
      {
        path: '/qa',
        name: 'qa',
        component: () => import('@/views/qa')
      },
      {
        path: '/video',
        name: 'video',
        component: () => import('@/views/video')
      }
    ]
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('@/views/search')
  },
  {
    path: '/article/:articleId',
    name: 'article',
    component: () => import('@/views/article'),
    props: true //开启props传参.
  }
]

// ------------------------------------------

// 创建路由实例
const router = new VueRouter({
  routes
})

// 对外输出路由组件
export default router
